package com.applet;

import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.util.StringUtils;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * 启动程序
 * 
 * @author ruoyi
 */
//开启knife4j
@EnableKnife4j
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
public class RuoYiApplication
{
    public static void main(String[] args)
    {
        // System.setProperty("spring.devtools.restart.enabled", "false");
//        SpringApplication.run(RuoYiApplication.class, args);
        ConfigurableApplicationContext run = SpringApplication.run(RuoYiApplication.class, args);
        System.out.println("(♥◠‿◠)ﾉﾞ  若依启动成功   ლ(´ڡ`ლ)ﾞ  \n" +
                " .-------.       ____     __        \n" +
                " |  _ _   \\      \\   \\   /  /    \n" +
                " | ( ' )  |       \\  _. /  '       \n" +
                " |(_ o _) /        _( )_ .'         \n" +
                " | (_,_).' __  ___(_ o _)'          \n" +
                " |  |\\ \\  |  ||   |(_,_)'         \n" +
                " |  | \\ `'   /|   `-'  /           \n" +
                " |  |  \\    /  \\      /           \n" +
                " ''-'   `'-'    `-..-'              ");
        System.out.println("===========  Knife4j接口文档地址  ===========");
        ConfigurableEnvironment environment = run.getEnvironment();
        //获取项目端口号
        String port = environment.getProperty("server.port");
        //获取项目根路径
        String path = environment.getProperty("server.servlet.context-path");
        if (!StringUtils.hasLength(path) || path.equals("/")) {
            path = "";
        }
        //获取项目主机名称
        try {
            // 获取项目访问主机名称
            String hostAddress = InetAddress.getLocalHost().getHostAddress();
            //内网访问地址
            System.out.println("内网访问地址:" + "http://" + hostAddress + ":" + port + path + "/doc.html");
            //本地访问地址
            System.out.println("本地访问地址:" + "http://" + "localhost:" + port + path + "/doc.html");
        } catch (UnknownHostException e) {
            throw new RuntimeException(e);
        }
    }
}
